package com.hl.toolkit.pay.controller;

import com.bdpay.*;
import com.tycoin.account.slaveentity.TycoinAccountRecharge;
import com.tycoin.account.slaveservice.TycoinAccountRechargeCallbackProcessService;
import com.tycoin.account.slaveservice.TycoinAccountRechargeService;
import com.tycoin.common.entity.BaiduPayInfo;
import com.tycoin.user.slaveentity.TycoinUser;
import com.tycoin.user.slaveservice.TycoinUserService;
import com.util.*;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 百度支付
 */
@Controller
@RequestMapping(value = { "/interface/BaiduPay" })
public class BaiduPayScannController extends AbstractController {

	@Autowired
	private TycoinAccountRechargeService tycoinAccountRechargeService;
	@Autowired
	private TycoinAccountRechargeCallbackProcessService tycoinAccountRechargeCallbackProcessService;

	@Autowired
	private TycoinUserService tycoinUserService;

	@RequestMapping(value = "/authCodePay", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String authCodePay(HttpServletRequest request, HttpServletResponse response) {
		String result = "";

		// ?goods_name=测试&goods_desc=测试商品&total_amount=1&pay_type=2&bank_no=201&pay_code=314301330640846567
		String goods_name = request.getParameter("goods_name");
		String total_amount = request.getParameter("total_amount");
		String pay_code = request.getParameter("pay_code");
		String addIp = IpRequestUtils.getRemoteHost(request);
		String userId = request.getParameter("userId");
		SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
		SimpleDateFormat formatter3 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		long currentInt = System.currentTimeMillis();
		String order_create_time = formatter.format(currentInt);
		String order_create_time3 = formatter3.format(currentInt);
		String order_no = "BD" + order_create_time + (int) (Math.random() * 100);
		;
		BaiduPayInfo baiduPayInfo = new BaiduPayInfo();

		baiduPayInfo.setAddIp(addIp);
		baiduPayInfo.setAuthCode(pay_code);
		baiduPayInfo.setCreatTime(currentInt);
		baiduPayInfo.setGoodsName(goods_name);
		baiduPayInfo.setCharge(Integer.valueOf(total_amount));
		baiduPayInfo.setUserId(Integer.valueOf(userId));
		baiduPayInfo.setOrderNo(order_no);

		TycoinAccountRecharge tycoinAccountRecharge = new TycoinAccountRecharge();

		tycoinAccountRecharge.setAddip(baiduPayInfo.getAddIp());
		tycoinAccountRecharge.setMoney(String.valueOf((int) baiduPayInfo.getCharge()));
		tycoinAccountRecharge.setMoneyfloat((float) baiduPayInfo.getCharge() / 100);

		tycoinAccountRecharge.setIsOnline("1");
		tycoinAccountRecharge.setUserId(userId);
		tycoinAccountRecharge.setPaymentStatus(0);
		tycoinAccountRecharge.setPaymentTime(order_create_time3);
		tycoinAccountRecharge.setPaymentId(baiduPayInfo.getOrderNo());
		tycoinAccountRecharge.setLogno(RandomUtils.getRandomString(16));
		tycoinAccountRecharge.setDateTime(baiduPayInfo.getCreatTime());
		tycoinAccountRecharge.setPayMode(3);
		tycoinAccountRechargeService.save(tycoinAccountRecharge);
		try {
			O2o_CodePayServlet O2o_CodePayServlet = new O2o_CodePayServlet();
			result = O2o_CodePayServlet.doPost(request, response, order_no, order_create_time);
			/**
			 * 返回数据 :{"ret":"0","msg":"OK","content":{"bfb_order_no":
			 * "2017052810023082131112818960548","order_no":"BD2017052823292214"
			 * ,"pay_result":"2","sign_method":"1","sp_no":"1002308213",
			 * "version":"1","sign":"66326b5142301d1aa3ee469cb2f00258"},"token":
			 * ""}<br/>
			 * 
			 */
			JSONObject resultJson = JSONObject.fromObject(result);
			String ret = resultJson.getString("ret");
			String msg = resultJson.getString("msg");
			tycoinAccountRecharge.setReturnText(result);

			if ("0".equals(ret) && "OK".equals(msg)) {
				JSONObject contentJson = JSONObject.fromObject(resultJson.get("content"));
				String return_order_no = contentJson.getString("order_no");
				String bfb_order_no = contentJson.getString("bfb_order_no");
				tycoinAccountRecharge.setShopTradeNo(bfb_order_no);
				if (order_no.equals(return_order_no)) {
					tycoinAccountRecharge.setPaymentStatus(1);
					tycoinAccountRecharge.setReturnText(result);
					tycoinAccountRecharge.setShopTradeNo(bfb_order_no);
					tycoinAccountRechargeService.save(tycoinAccountRecharge);
 					tycoinAccountRechargeCallbackProcessService.rechargeCallbackProcess(tycoinAccountRecharge);
				}
			} else {
				tycoinAccountRecharge.setPaymentStatus(2);
				tycoinAccountRecharge.setReturnText(result);
				tycoinAccountRechargeService.save(tycoinAccountRecharge);
			}

		} catch (ServletException e) {
		} catch (IOException e) {
		}

		return result;

	}

	@RequestMapping(value = "/weH5Pay", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String weH5Pay(HttpServletRequest request, HttpServletResponse response) {
		String result = "";
		String qqPaymentSwitch = LoadProperties.loadPropertiesValue("qqPaymentSwitch");
		System.out.println(qqPaymentSwitch);
		if ("1".equals(qqPaymentSwitch)) {
			// ?goods_name=测试&goods_desc=测试商品&total_amount=1&pay_type=2&bank_no=201&pay_code=314301330640846567
			String goods_name = request.getParameter("goods_name");
			String total_amount = request.getParameter("total_amount");
			String Logno = request.getParameter("Logno");
			String addIp = IpRequestUtils.getRemoteHost(request);
			String userId = request.getParameter("userId");
			SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
			SimpleDateFormat formatter3 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			long currentInt = System.currentTimeMillis();
			String order_create_time = formatter.format(currentInt);
			String order_create_time3 = formatter3.format(currentInt);
			long radom = (long) (Math.random() * 100);
			String order_no = "BD" + order_create_time + radom;
			BaiduPayInfo baiduPayInfo = new BaiduPayInfo();

			baiduPayInfo.setAddIp(addIp);
			baiduPayInfo.setCreatTime(currentInt);
			baiduPayInfo.setGoodsName(goods_name);
			baiduPayInfo.setCharge(Integer.valueOf(total_amount));

			baiduPayInfo.setUserId(Integer.valueOf(userId));
			baiduPayInfo.setOrderNo(order_no);

			TycoinAccountRecharge tycoinAccountRecharge = new TycoinAccountRecharge();

			tycoinAccountRecharge.setAddip(baiduPayInfo.getAddIp());
			tycoinAccountRecharge.setMoney(String.valueOf((int) baiduPayInfo.getCharge()));
			tycoinAccountRecharge.setMoneyfloat((float) baiduPayInfo.getCharge() / 100);
			tycoinAccountRecharge.setIsOnline("1");
			tycoinAccountRecharge.setUserId(userId);
			tycoinAccountRecharge.setPaymentStatus(0);
			String isMycharge = request.getParameter("isMycharge");
			if ("1".equals(isMycharge)) {
				tycoinAccountRecharge.setIsMycharge(1);
			}
			tycoinAccountRecharge.setPaymentTime(order_create_time3);
			tycoinAccountRecharge.setPaymentId(baiduPayInfo.getOrderNo());
			if (!StringUtil.isNull(Logno)) {
				tycoinAccountRecharge.setLogno(Logno);
			} else {
				Logno=RandomUtils.getRandomString(16);
				tycoinAccountRecharge.setLogno(Logno);
			}

			TycoinAccountRecharge tycoin = tycoinAccountRechargeService.findOneBylogno(Logno);
			if (tycoin != null && !StringUtil.isNull(String.valueOf(tycoin.getId()))) {
				result = "{\"result_code\":\"2001\",\"return_msg\":\" 订单号不能重复提交\"}";
				return result;
			}

			// 商家异步回调地址，可为空
			String bdPayNotifUrl = request.getParameter("bdPayNotifUrl");
			if (!StringUtil.isNull(bdPayNotifUrl)) {
				tycoinAccountRecharge.setShopNotifUrl(bdPayNotifUrl);

				try {
					tycoinAccountRecharge.setShopNotifUrl(URLDecoder.decode(bdPayNotifUrl, "UTF-8"));
				} catch (UnsupportedEncodingException e) {
					e.printStackTrace();
				}
			}
			tycoinAccountRecharge.setDateTime(baiduPayInfo.getCreatTime());
			tycoinAccountRecharge.setPayMode(3);

			tycoinAccountRechargeService.save(tycoinAccountRecharge);

			String resultUrl = "";
			try {
				PayWapServlet PayWapServlet = new PayWapServlet();
				resultUrl = PayWapServlet.doPost(request, response, order_no, order_create_time);
				JSONObject resultJson = JSONObject.fromObject(result);
				String ret = resultJson.getString("ret");
				String msg = resultJson.getString("msg");
				tycoinAccountRecharge.setReturnText(result);
				String bfb_order_no = resultJson.getString("bfb_order_no");
				tycoinAccountRecharge.setShopTradeNo(bfb_order_no);

				if ("0".equals(ret) && "OK".equals(msg)) {
					JSONObject contentJson = JSONObject.fromObject(resultJson.get("content"));

					String return_order_no = contentJson.getString("order_no");
					if (order_no.equals(return_order_no)) {
						tycoinAccountRechargeService.save(tycoinAccountRecharge);
					}
				}
			} catch (Exception e) {

			}
			result = "{\"code\":\"SUCCESS\",\"imgpayUrl\":\"" + resultUrl + "\",\"outTradeNo\":\"" + order_no + "\"}";
		} else {
			result = "{code:\"NOTICE\",resultMessage:\"对不起，百度支付通道已关闭已关闭\"}";
		}
		return result;
	}

	@RequestMapping(value = "/zxingCodePay", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String zxingCodePay(HttpServletRequest request, HttpServletResponse response) {
		String result = "";
		// ?goods_name=测试&goods_desc=测试商品&total_amount=1&pay_type=2&bank_no=201&pay_code=314301330640846567
		String goods_name = request.getParameter("goods_name");
		String total_amount = request.getParameter("total_amount");
		String addIp = IpRequestUtils.getRemoteHost(request);
		String userId = request.getParameter("userId");
		SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
		SimpleDateFormat formatter3 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

		long currentInt = System.currentTimeMillis();
		String order_create_time = formatter.format(currentInt);
		String order_create_time3 = formatter3.format(currentInt);

		String order_no = "BD" + order_create_time + (int) (Math.random() * 100);
		;
		BaiduPayInfo baiduPayInfo = new BaiduPayInfo();

		baiduPayInfo.setAddIp(addIp);
		baiduPayInfo.setCreatTime(currentInt);
		baiduPayInfo.setGoodsName(goods_name);
		baiduPayInfo.setCharge(Integer.valueOf(total_amount));
		baiduPayInfo.setUserId(Integer.valueOf(userId));
		baiduPayInfo.setOrderNo(order_no);

		TycoinAccountRecharge tycoinAccountRecharge = new TycoinAccountRecharge();

		tycoinAccountRecharge.setAddip(baiduPayInfo.getAddIp());
		tycoinAccountRecharge.setMoney(String.valueOf((int) (baiduPayInfo.getCharge())));
		tycoinAccountRecharge.setMoneyfloat(((float) baiduPayInfo.getCharge()) / 100);
		tycoinAccountRecharge.setIsOnline("1");
		tycoinAccountRecharge.setUserId(userId);
		tycoinAccountRecharge.setPaymentStatus(0);
		tycoinAccountRecharge.setPaymentId(baiduPayInfo.getOrderNo());

		String Logno = request.getParameter("Logno");
		if (!StringUtil.isNull(Logno)) {
			tycoinAccountRecharge.setLogno(Logno);
		} else {
			tycoinAccountRecharge.setLogno(RandomUtils.getRandomString(16));
		}
		tycoinAccountRecharge.setDateTime(baiduPayInfo.getCreatTime());
		tycoinAccountRecharge.setPayMode(3);
		tycoinAccountRecharge.setPaymentTime(order_create_time3);
		tycoinAccountRechargeService.save(tycoinAccountRecharge);

		try {
			O2o_CodeCreateServlet o2o_CodeCreateServlet = new O2o_CodeCreateServlet();
			result = o2o_CodeCreateServlet.doPost(request, response, order_no, order_create_time);

			JSONObject resultJson = JSONObject.fromObject(result);
			String ret = resultJson.getString("ret");
			String msg = resultJson.getString("msg");
			tycoinAccountRecharge.setReturnText(result);

			if ("0".equals(ret) && "OK".equals(msg)) {
				JSONObject contentJson = JSONObject.fromObject(resultJson.get("content"));
				String return_order_no = contentJson.getString("order_no");
				String bfb_order_no = contentJson.getString("bfb_order_no");
				tycoinAccountRecharge.setShopTradeNo(bfb_order_no);
				tycoinAccountRecharge.setPaymentStatus(0);
				tycoinAccountRechargeService.save(tycoinAccountRecharge);

			}
		} catch (Exception e) {

		}
		return result;
	}

	@RequestMapping(value = "/UnloginPay", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String UnloginPay(HttpServletRequest request, HttpServletResponse response) {
		String result = "";
		PayUnloginServlet payUnloginServlet = new PayUnloginServlet();
		try {
			String returnUrl = payUnloginServlet.doPost(request, response);
			result = returnUrl;
		} catch (ServletException e) {
		} catch (IOException e) {
		}

		return result;
	}

	@RequestMapping(value = "/payNeedLogin", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String payNeedLogin(HttpServletRequest request, HttpServletResponse response) {
		String result = "";
		PayNeedLoginServlet payNeedLoginServlet = new PayNeedLoginServlet();
		try {
			payNeedLoginServlet.doPost(request, response);
		} catch (ServletException e) {
			// e.printStackTrace();
		} catch (IOException e) {
			// e.printStackTrace();
		}

		return result;
	}

	@RequestMapping(value = "/findPayByTranNo", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String findScannPayByTran(HttpServletRequest request, HttpServletResponse response) {
		String result = "";
		String bfb_order_no = request.getParameter("bfb_order_no");
		String order_no = request.getParameter("orderNo");

		try {
			PayQueryOrderByNoServlet payQueryOrderByNoServlet = new PayQueryOrderByNoServlet(order_no);
			result = payQueryOrderByNoServlet.doPost(request, response);
		} catch (Exception e) {
		}

		return result;

	}
	
	
	@RequestMapping(value = "/findPayByTranNoNULL", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String findPayByTranNoNULL(HttpServletRequest request, HttpServletResponse response) {
		String result = "";
 		String paymentTime="2017-07-10 10:58:37";
  		
 		List <TycoinAccountRecharge> TycoinAccountRechargeList=tycoinAccountRechargeService.queryPaymentTime(paymentTime);
	    	String paymentIds="";
  	    for (TycoinAccountRecharge tycoinAccountRecharge : TycoinAccountRechargeList) {
  	    	PayQueryOrderByNoServlet payQueryOrderByNoServlet = new PayQueryOrderByNoServlet(tycoinAccountRecharge.getPaymentId());
			try {
				result = payQueryOrderByNoServlet.doPost(request, response);
			} catch (ServletException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
 	    	JSONObject json= JSONObject.fromObject(result);
 	    	String code= String.valueOf(json.get("code"));
 	    	String resultMessage = "";
 	    	boolean bool=true;
			  if ("SUCCESS".equals(code)) {
				resultMessage = "交易支付成功";
 			    String shopNotifUrl=tycoinAccountRecharge.getShopNotifUrl();
 	  			  if(StringUtil.isNotNull(shopNotifUrl)){
					  System.out.println("开始商户异步回调shopNotifUrl="+shopNotifUrl+"&resultMessage="+resultMessage+"&code=TRADE_SUCCESS&TradeNo="+tycoinAccountRecharge.getShopTradeNo()+"&paymentId="+tycoinAccountRecharge.getPaymentId());
					 HttpClientUtils  hct=new HttpClientUtils();
					hct.get(shopNotifUrl+"&resultMessage="+resultMessage+"&code=TRADE_SUCCESS&TradeNo="+tycoinAccountRecharge.getShopTradeNo()+"&paymentId="+tycoinAccountRecharge.getPaymentId());
 					tycoinAccountRecharge.setPaymentStatus(1);
					tycoinAccountRecharge.setReturnText(result);
					tycoinAccountRechargeService.save(tycoinAccountRecharge);
					paymentIds+=tycoinAccountRecharge.getPaymentId()+",";
 	  			  }
			  } 
 		}
 
 	    return paymentIds;

	}

	@RequestMapping(value = "/refundByTranNo", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String refundByTranNo(HttpServletRequest request, HttpServletResponse response) {
		String result = "";
		Map<String, String> paramMap = new HashMap<String, String>();

		String paymentId = request.getParameter("paymentId");
		String Amount = request.getParameter("Amount");
		paramMap.put("paymentId", paymentId);
		paramMap.put("Amount", Amount);
		String resultStr = isNotparam(paramMap);
		if (!StringUtil.isNull(resultStr)) {
			return resultStr;
		} else {
			Map<String, String> resultMap = new HashMap<String, String>();

			try {
				RefundServlet refundServlet = new RefundServlet();
				result = refundServlet.doPost(request, response);

				/***
				 * <?xml version=\"1.0\" encoding=\"gbk\" ?>\r\n
				 * <response><cashback_amount>1</cashback_amount>
				 * <sp_no>1002308213</sp_no>
				 * <order_no>BD2017061911485081</order_no>
				 * <bfb_order_no>2017061910023082131112849762857</bfb_order_no>
				 * <sp_refund_no>2017062016105842</sp_refund_no>
				 * <ret_code>10</ret_code><ret_detail>account amount less than
				 * refund amount</ret_detail></response>
				 */

				resultMap = XMLUtils.getResult(result);
				result = JSONObject.fromObject(resultMap).toString();
				String ret_code = resultMap.get("ret_code");
				String cashback_amount = resultMap.get("cashback_amount");
				String order_no = resultMap.get("order_no");
				String bfb_order_no = resultMap.get("bfb_order_no");
				TycoinAccountRecharge tycoinAccountRecharge = tycoinAccountRechargeService.findOneBypaymentId(paymentId);
				tycoinAccountRecharge.setShopTradeNo(bfb_order_no);
				if ("0".equals(ret_code) && tycoinAccountRecharge.getMoney().equals(cashback_amount)) {
					tycoinAccountRechargeService.save(tycoinAccountRecharge);
					tycoinAccountRechargeCallbackProcessService.tycoinAccountRechargeCallBackSaveOrUpdate(tycoinAccountRecharge,
							request, response);
				}
			} catch (Exception e) {
			}
		}

		return result;
	}

	@RequestMapping(value = "/notiyReturn", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public void notiy_return(HttpServletRequest request, HttpServletResponse response) {
		System.out.println("------------我已经进入了异步回调----------");

		String getStrPre = request.getQueryString();
		// url解码
		String getStr = null;
		try {
			getStr = URLDecoder.decode(getStrPre, "gbk");
		} catch (UnsupportedEncodingException e1) {
		}
		// 把返回的参数用split取出来
		String[] resultStrTemp = getStr.split("&");
		String[] resultStr = new String[resultStrTemp.length - 1];
		// 取签名串
		String signtemp = resultStrTemp[resultStrTemp.length - 1];
		String sign = signtemp.substring(signtemp.indexOf("=") + 1, signtemp.length());

		for (int i = 0; i < resultStrTemp.length - 1; i++) {
			resultStr[i] = resultStrTemp[i];
			System.out.println(resultStr[i]);
		}
		/**
		 * 3、 调用bfb_sdk_comm里make_sign方法生成签名串
		 */

		// 签名拼接，需要去掉返回的签名串字段sign
		String Localsign = new BfbSdkComm().make_sign(resultStr);

		/***
		 * 
		 * [bank_no=, bfb_order_create_time=20170529102211,
		 * bfb_order_no=2017052910023082131112819158344, buyer_sp_username=,
		 * currency=1, extra=, fee_amount=0, input_charset=1,
		 * order_no=BD2017052910224810, pay_result=1, pay_time=20170529102219,
		 * pay_type=1, sign_method=1, sp_no=1002308213, total_amount=1,
		 * transport_amount=0, unit_amount=1, unit_count=1, version=2]
		 */
		String order_no = resultStr[8];
		String bfb_order_no = resultStr[2];
		String total_amount = resultStr[14];
		String pay_time = resultStr[10];
		String pay_result = resultStr[9];

		order_no = order_no.replace("order_no=", "");
		bfb_order_no = bfb_order_no.replace("bfb_order_no=", "");
		pay_result = pay_result.replace("pay_result=", "");
		ReturnServlet returnServlet = new ReturnServlet();
		System.out.println("order_no为：" + order_no);

		String resultMessage = "";
		if ("1".equals(pay_result)) {
			resultMessage = "支付成功";
		} else if ("2".equals(pay_result)) {
			resultMessage = "等待支付";
		} else if ("3".equals(pay_result)) {
			resultMessage = "退款成功";
		}

		try {
			returnServlet.doGet(request, response);
			TycoinAccountRecharge tycoinAccountRecharge = tycoinAccountRechargeService.findOneBypaymentId(order_no);
			if (tycoinAccountRecharge != null && tycoinAccountRecharge.getPaymentStatus() != 1) {
				tycoinAccountRecharge.setShopTradeNo(bfb_order_no);
				tycoinAccountRecharge.setPaymentStatus(1);
				tycoinAccountRechargeService.save(tycoinAccountRecharge);
 
				String shopNotifUrl = tycoinAccountRecharge.getShopNotifUrl();
				if (StringUtil.isNotNull(shopNotifUrl)) {
					System.out.println("开始商户异步回调shopNotifUrl=" + shopNotifUrl + "&code=" + pay_result
							+ "&resultMessage=" + resultMessage + "&TradeNo=" + tycoinAccountRecharge.getShopTradeNo()
							+ "&paymentId=" + tycoinAccountRecharge.getPaymentId());
					HttpClientUtils hct = new HttpClientUtils();
					hct.get(shopNotifUrl + "&code=" + pay_result + "&resultMessage=" + resultMessage + "&TradeNo="
							+ tycoinAccountRecharge.getPaymentId() + "&paymentId=" + tycoinAccountRecharge.getPaymentId());
				}
				TycoinUser tycoinUser = tycoinUserService.findById(Long.valueOf(tycoinAccountRecharge.getUserId()));
				if (tycoinUser != null && StringUtil.isNotNull(String.valueOf(tycoinUser.getId()))) {
					tycoinAccountRechargeCallbackProcessService.rechargeCallbackProcess(tycoinAccountRecharge);
				}

			} else {
				if (tycoinAccountRecharge != null) {
					String shopNotifUrl = tycoinAccountRecharge.getShopNotifUrl();
					if (StringUtil.isNotNull(shopNotifUrl)) {
						HttpClientUtils hct = new HttpClientUtils();
						hct.get(shopNotifUrl + "&code=" + pay_result + "&resultMessage=" + resultMessage + "&TradeNo="
								+ tycoinAccountRecharge.getShopTradeNo() + "&paymentId="
								+ tycoinAccountRecharge.getPaymentId());
					}
				}
			}

		} catch (ServletException e) {

		} catch (IOException e) {

		}

	}

}
